package cc.comac.saic.hkhy.jsrj.gj.inttools.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import cc.comac.saic.hkhy.jsrj.gj.inttools.entity.ProjectInfo;
import cc.comac.saic.hkhy.jsrj.gj.inttools.service.ProjectInfoService;


/**
 * 项目信息(ProjectInfo)表控制层
 *
 * @author makejava
 * @since 2025-07-02 18:26:30
 */
@RestController
@RequestMapping("project")
public class ProjectInfoController {
    @Autowired
    private ProjectInfoService projectInfoService;

    /**
     * 分页查询
     *
     * @param projectInfo 筛选条件
     * @return 查询结果
     */
    @GetMapping
    public ResponseEntity<List<ProjectInfo>> queryByCondition(ProjectInfo projectInfo) {
        return ResponseEntity.ok(this.projectInfoService.queryByCondition(projectInfo));
    }

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("{id}")
    public ResponseEntity<ProjectInfo> queryById(@PathVariable("id") Long id) {
        return ResponseEntity.ok(this.projectInfoService.queryById(id));
    }

    /**
     * 新增数据
     *
     * @param projectInfo 实体
     * @return 新增结果
     */
    @PostMapping
    public ResponseEntity<ProjectInfo> add(ProjectInfo projectInfo) {
        return ResponseEntity.ok(this.projectInfoService.insert(projectInfo));
    }

    /**
     * 编辑数据
     *
     * @param projectInfo 实体
     * @return 编辑结果
     */
    @PutMapping
    public ResponseEntity<ProjectInfo> edit(ProjectInfo projectInfo) {
        return ResponseEntity.ok(this.projectInfoService.update(projectInfo));
    }

    /**
     * 删除数据
     *
     * @param id 主键
     * @return 删除是否成功
     */
    @DeleteMapping
    public ResponseEntity<Boolean> deleteById(Long id) {
        return ResponseEntity.ok(this.projectInfoService.deleteById(id));
    }

}

